package cn.xopencode.userservice.service;

import cn.xopencode.oss.rpc.permission.PositionRpc;
import cn.xopencode.userservice.convert.UserConvert;
import cn.xopencode.userservice.dal.mysql.dataobject.UserDO;
import cn.xopencode.userservice.dal.mysql.mapper.UserMapper;
import cn.xopencode.userservice.rpc.user.dto.UserDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    @DubboReference(version = "${dubbo.consumer.PositionRpc.version}", validation = "false")
    private PositionRpc positionRpc;

    public UserDTO getUser(String userId) {
        UserDTO userDTO = null;
        UserDO userDO = userMapper.selectById(userId);
        if (null != userDO) {
            userDTO = UserConvert.INSTANCE.convert(userDO);
        }
        return userDTO;
    }

}
